<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>待付款</title>
		<link rel="stylesheet" type="text/css" href="css/site.css" />
		<!-- 引入样式 -->
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">

		<!-- 引入组件 -->
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vant@1.6/lib/vant.min.js"></script>
	</head>
	<body>
		<div id="app">
			<!-- 头部 -->
			<van-nav-bar id="S_bar" fixed=true title="代付款订单" left-arrow @click-left="onClickLeft"></van-nav-bar>
			<!-- 内容 -->
			<van-panel v-if="list.length != 0" v-for="list in list" title="订单编号" :desc="list.bianhao" :status="list.iszhifu">
				<van-row class="S_ding" span="24" align="center">
					<van-col span="6"><img src="img/PingTouGe.jpg" width="100%"></van-col>
					<van-col span="16" offset="1">
						<van-col span="19">{{list.mingcheng}}</van-col>
						<van-col span="5">￥ {{list.jiage}}</van-col>
						<van-col span="19">{{list.guige}}</van-col>
						<van-col span="5">x {{list.count}}</van-col>
					</van-col>
				</van-row>
				<div class="S_nr" align="center">共一件商品，合计：￥{{list.price}}（含运费：￥{{list.yunfei}}）</div>
				<div slot="footer" align="right">
					<van-button class="S_An" size="small" type="danger">支付</van-button>
					<van-button class="S_An" size="small">取消订单</van-button>
				</div>
			</van-panel>
			<div v-if="list.length == 0" class="nonews" align="center">
				<van-icon name="other-pay" size="50px"></van-icon>
				<div>暂无待付款订单</div>
			</div>
		</div>
		<script src="js/ajax.js"></script>
		<script>
			var app = new Vue({
				el: "#app",
				data: {
					list: []
				},
				computed: {
					price(){
						for(let i = 0; i < this.list.length; i++){
							this.list[i].price = this.list[i].jiage * this.list[i].count + this.list[i].yunfei;
						}
					}
				},
				methods: {
					onClickLeft() {
						plus.webview.create("index.html", "index").show();
					}
				},
				mounted() {
					ajax({
						url: "http://dsapi.ysd3g.com/api/MyOrderList",
						data: {
							key: localStorage.getItem('Key')
						},
						dataType: "jsonp",
						success: function(res) {
							console.log(res)
							if (!res.Error) {
								for (var i = 0; i < res.Data.length; i++) {
									var obj = {};
									// 返回值名称不确定
									// obj.bianhao = res.Data[i].bianhao
									// obj.iszhifu = res.Data[i].iszhifu
									// obj.mingcheng = res.Data[i].mingcheng
									// obj.jiage = res.Data[i].jiage
									// obj.guige = res.Data[i].guige
									// obj.count = res.Data[i].count
									// obj.yunfei = res.Data[i].yunfei
									_this.list.push(obj)
								}
							} else {
								alert("登陆失效，请重新登陆")
								plus.webview.create("login.html", "login").show();
							}
						}
					})
					this.price()
				}
			})
		</script>
	</body>
</html>
